<template>
  <div class='container'>
    <el-dialog title="预览文章" :visible="showPreviewDialog" @close="closeDialogFn" :close-on-click-modal="false">
      <div class="title">
        <h2>{{rowList.title}}</h2>
        <span>{{$parent.time(rowList.createTime)}}</span>&nbsp;&nbsp;
        <span>超级管理员</span>&nbsp;&nbsp;
        <span class="el-icon-view">&nbsp;{{rowList.visits}}</span>
      </div>
      <div v-html="rowList.articleBody" class="content"></div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'previewArticle',
  props: {
    showPreviewDialog: {
      type: Boolean,
      default: false
    },
    rowList: { // 点击的这条数据
      type: Object,
      // 复杂类型设置默认值 需要使用函数的方式
      default: () => {}
    }
  },
  methods: {
    closeDialogFn () {
      this.$emit('update:showPreviewDialog', false)
    }
  }
}
</script>

<style scoped lang='scss'>
.title {
  border-bottom: 1px dashed #ccc;
  padding-bottom: 10px;
}
.title h2 {
  margin: 0;
  padding: 0;
  margin-bottom: 6px;
}
.content {
  background: #f5f5f5;
  padding: 10px;
}
span {
  padding: 6px;
}
</style>
